home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / program / vb_eliza.zip / CHAT.BAS < prev    next >
BASIC Source File  |  1996-07-30  |  23KB  |  716 lines

  1. Attribute VB_Name = "Module1"
  2.  
  3. Public Function Greeting() As String
  4.  Dim Choice As Integer
  5.   Randomize
  6.   Choice = CInt(6 * Rnd + 1)
  7.   Select Case Choice
  8.     Case 1
  9.       Greeting = "Hello, how may I help you?"
  10.     Case 2
  11.       Greeting = "Greetings. What would you like to talk about?"
  12.     Case 3
  13.       Greeting = "Good day. Please tell me your problems."
  14.     Case 4
  15.       Greeting = "What is on your mind today?"
  16.     Case 5
  17.       Greeting = "Please begin when you are ready."
  18.     Case Else
  19.       Greeting = "Hello, what is your question?"
  20.   End Select
  21. End Function
  22.  
  23. Public Function NewReply(LastReply As String, Question As String) As String
  24.  Dim Choice As Integer
  25.  Dim Location As Integer
  26.  Dim TempReply As String
  27.   Randomize
  28.   Question = UCase(Question)
  29.  
  30.   Do ' This Do-Until loop keeps ELIZA from repeating herself
  31.     Do
  32.   
  33.   ' Check for "How", "Who", "What", "When", "Why", or "Where" keywords
  34.     If ((InStr(Question, "HOW")) > 0) Or ((InStr(Question, "WHO")) > 0) Or ((InStr(Question, "WHAT")) > 0) Or ((InStr(Question, "WHEN")) > 0) Or ((InStr(Question, "WHERE")) > 0) Or ((InStr(Question, "WHY")) > 0) Then
  35.       Choice = CInt(9 * Rnd + 1)
  36.       Select Case Choice
  37.         Case 1
  38.           NewReply = "Why do you ask?"
  39.         Case 2
  40.           NewReply = "Does that question interest you?"
  41.         Case 3
  42.           NewReply = "What answer would please you the most?"
  43.         Case 4
  44.           NewReply = "Are such questions on your mind often?"
  45.         Case 5
  46.           NewReply = "What is it that you really want to know?"
  47.         Case 6
  48.           NewReply = "Have you asked anyone else?"
  49.         Case 7
  50.           NewReply = "Have you asked such questions before?"
  51.         Case 8
  52.           NewReply = "What else comes to mind when you ask that?"
  53.         Case Else
  54.           NewReply = "What do you think?"
  55.       End Select
  56.       Exit Do
  57.     End If
  58.   
  59.   ' Check for "Mother", "Father", "Brother", "Sister", or "Family" keywords
  60.     If ((InStr(Question, "MOTHER")) > 0) Or ((InStr(Question, "BROTHER")) > 0) Or ((InStr(Question, "WHAT")) > 0) Or ((InStr(Question, "WHEN")) > 0) Or ((InStr(Question, "SISTER")) > 0) Or ((InStr(Question, "FAMILY")) > 0) Then
  61.       Choice = CInt(9 * Rnd + 1)
  62.       Select Case Choice
  63.         Case 1
  64.           NewReply = "Why do you mention your family?"
  65.         Case 2
  66.           NewReply = "Did you get along with your family?"
  67.         Case 3
  68.           NewReply = "How does your family treat you?"
  69.         Case 4
  70.           NewReply = "Were you ever close to your family?"
  71.         Case 5
  72.           NewReply = "Did you have a happy childhood?"
  73.         Case 6
  74.           NewReply = "Do you like your family members?"
  75.         Case 7
  76.           NewReply = "Did your family ask you to talk to me?"
  77.         Case 8
  78.           NewReply = "What kind of childhood did you have?"
  79.         Case Else
  80.           NewReply = "Do you think about your family often?"
  81.       End Select
  82.       Exit Do
  83.     End If
  84.   
  85.   ' Check for "Hello" answer
  86.     If ((InStr(Question, "HELLO")) > 0) Then
  87.       Choice = CInt(4 * Rnd + 1)
  88.       Select Case Choice
  89.         Case 1
  90.           NewReply = "How do you do. How can I help you?"
  91.         Case 2
  92.           NewReply = "Greetings to you too. What shall we talk about today?"
  93.         Case 3
  94.           NewReply = "Bon jour. Shall we get to business now?"
  95.         Case Else
  96.           NewReply = "Please make yourself comfortable and let's begin, shall we?"
  97.       End Select
  98.       Exit Do
  99.     End If
  100.   
  101.   ' Check for profanity
  102.     If ((InStr(Question, "FUCK")) > 0) Or ((InStr(Question, "SHIT")) > 0) Or ((InStr(Question, "HELL")) > 0) Or ((InStr(Question, "DAMN")) > 0) Then
  103.       Choice = CInt(4 * Rnd + 1)
  104.       Select Case Choice
  105.         Case 1
  106.           NewReply = "Please don't use four-letter words."
  107.         Case 2
  108.           NewReply = "Profanity is not necessary."
  109.         Case 3
  110.           NewReply = "Do you use such foul language often?"
  111.         Case Else
  112.           NewReply = "You don't have to use profanity to express yourself."
  113.       End Select
  114.       Exit Do
  115.     End If
  116.   
  117.   ' Check for "Name" keyword
  118.     If ((InStr(Question, "NAME")) > 0) Then
  119.       Choice = CInt(4 * Rnd + 1)
  120.       Select Case Choice
  121.         Case 1
  122.           NewReply = "As Shakespeare said, 'What's in a name?'"
  123.         Case 2
  124.           NewReply = "Are names important to you?"
  125.         Case 3
  126.           NewReply = "Why do you mention names at all?"
  127.         Case Else
  128.           NewReply = "Names are not important at this time."
  129.       End Select
  130.       Exit Do
  131.     End If
  132.   
  133.   ' Check for "Thank" keyword
  134.     If ((InStr(Question, "THANK")) > 0) Then
  135.       Choice = CInt(4 * Rnd + 1)
  136.       Select Case Choice
  137.         Case 1
  138.           NewReply = "You're welcome."
  139.         Case 2
  140.           NewReply = "No problem."
  141.         Case 3
  142.           NewReply = "I'm always glad to be of service to you."
  143.         Case Else
  144.           NewReply = "Do you feel better now?"
  145.       End Select
  146.       Exit Do
  147.     End If
  148.   
  149.   ' Check for "Cause" keyword
  150.     If ((InStr(Question, "CAUSE")) > 0) Then
  151.       Choice = CInt(4 * Rnd + 1)
  152.       Select Case Choice
  153.         Case 1
  154.           NewReply = "Is that the real reason?"
  155.         Case 2
  156.           NewReply = "Do any other reasons come to mind?"
  157.         Case 3
  158.           NewReply = "Does that reason explain anything else?"
  159.         Case Else
  160.           NewReply = "What other reasons might there be?"
  161.       End Select
  162.       Exit Do
  163.     End If
  164.   
  165.   ' Check for "Sorry" keyword
  166.     If ((InStr(Question, "SORRY")) > 0) Then
  167.       Choice = CInt(5 * Rnd + 1)
  168.       Select Case Choice
  169.         Case 1
  170.           NewReply = "Please don't feel the need to apologize."
  171.         Case 2
  172.           NewReply = "Apologies are not necessary."
  173.         Case 3
  174.           NewReply = "How do you feel when you apologize?"
  175.         Case 4
  176.           NewReply = "Don't be so defensive."
  177.         Case Else
  178.           NewReply = "That's okay. Please continue."
  179.       End Select
  180.       Exit Do
  181.     End If
  182.     
  183.   ' Check for "Dream" keyword
  184.     If ((InStr(Question, "DREAM")) > 0) Then
  185.       Choice = CInt(5 * Rnd + 1)
  186.       Select Case Choice
  187.         Case 1
  188.           NewReply = "What does that dream suggest to you?"
  189.         Case 2
  190.           NewReply = "Do you dream often?"
  191.         Case 3
  192.           NewReply = "Are you disturbed by dreams?"
  193.         Case 4
  194.           NewReply = "Dreaming is natural."
  195.         Case Else
  196.           NewReply = "What do your dreams reveal about your thoughts?"
  197.       End Select
  198.       Exit Do
  199.     End If
  200.   
  201.   ' Check for "Maybe" keyword
  202.     If ((InStr(Question, "MAYBE")) > 0) Then
  203.       Choice = CInt(6 * Rnd + 1)
  204.       Select Case Choice
  205.         Case 1
  206.           NewReply = "You don't seem quite certain."
  207.         Case 2
  208.           NewReply = "Why the uncertain tone?"
  209.         Case 3
  210.           NewReply = "Can't you be more positive?"
  211.         Case 4
  212.           NewReply = "You aren't sure?"
  213.         Case 5
  214.           NewReply = "Don't you know?"
  215.         Case Else
  216.           NewReply = "Perhaps that might be true after all."
  217.       End Select
  218.       Exit Do
  219.     End If
  220.   
  221.   ' Check for "Always" keyword
  222.     If ((InStr(Question, "ALWAYS")) > 0) Then
  223.       Choice = CInt(5 * Rnd + 1)
  224.       Select Case Choice
  225.         Case 1
  226.           NewReply = "Can you think of an example?"
  227.         Case 2
  228.           NewReply = "When?"
  229.         Case 3
  230.           NewReply = "What are you thinking about now?"
  231.         Case 4
  232.           NewReply = "Really...always?"
  233.         Case Else
  234.           NewReply = "Perhaps that might be true occasionally."
  235.       End Select
  236.       Exit Do
  237.     End If
  238.   
  239.   ' Check for "Alike" keyword
  240.     If ((InStr(Question, "ALIKE")) > 0) Then
  241.       Choice = CInt(7 * Rnd + 1)
  242.       Select Case Choice
  243.         Case 1
  244.           NewReply = "In what way?"
  245.         Case 2
  246.           NewReply = "What similarities do you see?"
  247.         Case 3
  248.           NewReply = "What does the similarity suggest to you?"
  249.         Case 4
  250.           NewReply = "Could there really be a connection?"
  251.         Case 5
  252.